package com.atguigu.product.controller;


import com.atguigu.Product.Product;
import com.atguigu.product.service.ProductService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {
    @Autowired
    ProductService productService;
    /**
     * 获取商品信息
     * @param id
     * @return
     */
    @GetMapping("/getProduct/{id}")
    public Product getProductById(@PathVariable("id") Long id, HttpServletRequest request) {
        String header = request.getHeader("X-Token");
        System.out.println(header);

        return productService.getProductById(id);
    }
}
